package com.flida.echart.basic.service;

import com.flida.echart.basic.account.service.SysUserService;
import com.flida.echart.basic.api.account.entity.SysUserEntity;
import com.flida.echart.basic.api.service.GateUserService;
import com.flida.echart.basic.utils.AreaHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created by yzc on 2016/12/7.
 */
@Service("gateUserService")
public class GateUserServiceImpl implements GateUserService {


    @Autowired
    public AreaHelper areaHelper;

    @Autowired
    public SysUserService sysUserService;



    public String getAreaName(String cityid) {
        return areaHelper.getAreaName(cityid);
    }

    /**
     * 查询用户的所有权限
     *
     * @param userId 用户ID
     */
    public List<String> queryAllPerms(Long userId) {
        return sysUserService.queryAllPerms(userId);
    }

    /**
     * 查询用户的所有菜单ID
     *
     * @param userId
     */
    public List<Long> queryAllMenuId(Long userId) {
        return sysUserService.queryAllMenuId(userId);
    }

    /**
     * 根据用户名，查询系统用户
     *
     * @param username
     */
    public SysUserEntity queryByUserName(String username) {
        return sysUserService.queryByUserName(username);
    }

    /**
     * 根据用户ID，查询用户
     *
     * @param userId
     * @return
     */
    public SysUserEntity queryObject(Long userId) {
        return sysUserService.queryObject(userId);
    }

    /**
     * 查询用户列表
     *
     * @param map
     */
    public List<SysUserEntity> queryList(Map<String, Object> map) {
        return sysUserService.queryList(map);
    }

    /**
     * 查询总数
     *
     * @param map
     */
    public int queryTotal(Map<String, Object> map) {
        return sysUserService.queryTotal(map);

    }

    /**
     * 保存用户
     *
     * @param user
     */
    public void save(SysUserEntity user) {
         sysUserService.save(user);

    }

    /**
     * 修改用户
     *
     * @param user
     */
    public void update(SysUserEntity user) {
        sysUserService.update(user);

    }

    /**
     * 删除用户
     *
     * @param userIds
     */
    public void deleteBatch(Long[] userIds) {
        sysUserService.deleteBatch(userIds);

    }

    /**
     * 修改密码
     *
     * @param userId      用户ID
     * @param password    原密码
     * @param newPassword 新密码
     */
    public int updatePassword(Long userId, String password, String newPassword) {
       return sysUserService.updatePassword(userId,password,newPassword);
    }

}
